home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / hdf3_2r2.lha / HDF3.2r2 / test / tsdntf.f < prev    next >
Encoding:
Text File  |  1992-10-28  |  7.8 KB  |  289 lines

  1. C***************************************************************************
  2. C
  3. C
  4. C                         NCSA HDF version 3.2r2
  5. C                            October 30, 1992
  6. C
  7. C NCSA HDF Version 3.2 source code and documentation are in the public
  8. C domain.  Specifically, we give to the public domain all rights for future
  9. C licensing of the source code, all resale rights, and all publishing rights.
  10. C
  11. C We ask, but do not require, that the following message be included in all
  12. C derived works:
  13. C
  14. C Portions developed at the National Center for Supercomputing Applications at
  15. C the University of Illinois at Urbana-Champaign, in collaboration with the
  16. C Information Technology Institute of Singapore.
  17. C
  18. C THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  19. C SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  20. C WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  21. C
  22. C***************************************************************************
  23.  
  24. C
  25. C $Header: /hdf/hdf/v3.2r2/test/RCS/tsdntf.f,v 1.5 1992/06/30 20:34:24 chouck beta koziol $
  26. C
  27. C $Log: tsdntf.f,v $
  28. c Revision 1.5  1992/06/30  20:34:24  chouck
  29. c Fortran character passing problems were making the int8 tests
  30. c fail.  Change int8 variables to 'byte' for VMS
  31. c
  32. c Revision 1.4  1992/06/26  20:44:33  chouck
  33. c Oops, filename change made lines too long
  34. c
  35. c Revision 1.2  1992/05/28  17:31:32  chouck
  36. c Changed output file names
  37. c
  38. c Revision 1.1  1992/04/27  17:28:04  sxu
  39. c Initial revision
  40. c
  41. c Revision 1.1  1992/02/29  19:32:51  mfolk
  42. c Initial revision
  43. c
  44. C
  45.       program tdfsd_ntF
  46. C
  47. C
  48. C  Program to test writing SDSs with different types of data.
  49. C
  50. C  Input file:  none
  51. C  Output files:  o.hdf.1, o.hdf.2, ... o.hdf.5
  52. C
  53. C  **** VMS users ****
  54. C
  55. C  VMS has a special way of handling the passsing of character
  56. C   strings between C and FORTRAN.  For these tests to work 
  57. C   correctly, you must change the definition of i8 and ti8
  58. C   to be 'byte' not 'character'  You will also need to remove
  59. C   a couple of calls to char().  If you search on the string 
  60. C   VMS you should be able to find all of the necessary changes.
  61. C
  62.       integer dspdata, dsgdata, dsadata, dssdims, dssnt
  63.  
  64.       real*8 f64(10,10), tf64(10,10)
  65.       real*4 f32(10,10), tf32(10,10)
  66.       integer*2 i16(10,10), ti16(10,10)
  67.       integer*4 i32(10,10), ti32(10,10)
  68.  
  69. C  Change these to be of type 'byte' for VMS
  70. C      byte      i8(10,10), ti8(10,10)
  71.       character i8(10,10), ti8(10,10)
  72.  
  73.       
  74.       integer i, j, err, err1, err2
  75.       integer rank
  76.       integer dims(2)
  77.       integer number_failed
  78.       integer DFNT_FLOAT64, DFNT_FLOAT32, DFNT_INT8
  79.       integer DFNT_INT16, DFNT_INT32
  80.   
  81.       number_failed = 0
  82.       DFNT_FLOAT64 = 6
  83.       DFNT_FLOAT32 = 5
  84.       DFNT_INT8 = 20
  85.       DFNT_INT16 = 22
  86.       DFNT_INT32 = 24
  87.       rank = 2
  88.       dims(1) = 10
  89.       dims(2) = 10
  90.   
  91.       print *, 'Creating arrays...'
  92.   
  93.       do 110 i=1,10
  94.           do 100 j=1,10
  95.             f64(i,j) = (i * 10) + j
  96.           f32(i,j) = (i * 10) + j
  97. C  Use the following line for VMS
  98. C            i8(i,j) =  (i * 10) + j
  99.            i8(i,j) = char( (i * 10) + j )
  100.           i16(i,j) = (i * 10) + j
  101.           i32(i,j) = (i * 10) + j
  102.   100     continue
  103.   110 continue
  104.   
  105.       err = dssdims(rank, dims)
  106.   
  107. C  individual files 
  108.       print *,'Testing arrays in individual files...'
  109.   
  110.       err = dssnt(DFNT_FLOAT64)
  111.       err1 = dspdata('o1.hdf', rank, dims, f64)
  112.       err2 = dsgdata('o1.hdf', rank, dims, tf64)
  113.       print *,'Write: ', err1, '    Read: ', err2
  114.       err = 0
  115.       do 160 i=1,10
  116.           do 150 j=1,10
  117.           if (f64(i,j).ne.tf64(i,j)) err = 1
  118.           tf64(i,j) = 0.0
  119.   150     continue
  120.   160 continue
  121.  
  122.       call err_check(err, number_failed, 'float64')
  123.  
  124.       err = dssnt(DFNT_FLOAT32)
  125.       err1 = dspdata('o2.hdf', rank, dims, f32)
  126.       err2 = dsgdata('o2.hdf', rank, dims, tf32)
  127.       print *,'Write: ', err1, '    Read: ', err2
  128.       err = 0
  129.       do 210 i=1,10
  130.           do 200 j=1,10
  131.           if (f32(i,j).ne.tf32(i,j)) err = 1
  132.           tf32(i,j) = 0.0
  133.   200     continue
  134.   210 continue
  135.  
  136.       call err_check(err, number_failed, 'float32')
  137.  
  138.       err = dssnt(DFNT_INT8)
  139.       err1 = dspdata('o3.hdf', rank, dims, i8)
  140.       err2 = dsgdata('o3.hdf', rank, dims, ti8)
  141.       print *,'Write: ', err1, '    Read: ', err2
  142.       err = 0
  143.       do 310 i=1,10
  144.           do 300 j=1,10
  145.           if (i8(i,j).ne.ti8(i,j)) err = 1
  146. C Use the following line for VMS
  147. C           ti8(i,j) = 0
  148.           ti8(i,j) = char(0)
  149.   300     continue
  150.   310 continue
  151.  
  152.       call err_check(err, number_failed, 'int8')
  153.  
  154.       err = dssnt(DFNT_INT16)
  155.       err1 = dspdata('o4.hdf', rank, dims, i16)
  156.       err2 = dsgdata('o4.hdf', rank, dims, ti16)
  157.       print *,'Write: ', err1, '    Read: ', err2
  158.       err = 0
  159.       do 410 i=1,10
  160.           do 400 j=1,10
  161.            if (i16(i,j).ne.ti16(i,j)) err = 1
  162.           ti16(i,j) = 0
  163.   400     continue
  164.   410 continue
  165.  
  166.       call err_check(err, number_failed, 'int16')
  167.  
  168.       err = dssnt(DFNT_INT32)
  169.       err1 = dspdata('o5.hdf', rank, dims, i32)
  170.       err2 = dsgdata('o5.hdf', rank, dims, ti32)
  171.       print *,'Write: ', err1, '    Read: ', err2
  172.       err = 0
  173.       do 510 i=1,10
  174.           do 500 j=1,10
  175.           if (i32(i,j).ne.ti32(i,j)) err = 1
  176.           ti32(i,j) = 0
  177.   500     continue
  178.   510 continue
  179.  
  180.       call err_check(err, number_failed, 'int32')
  181.  
  182.  
  183.       print *, 'Writing arrays to single file.'
  184.       print *, 'Error values: '
  185. C
  186.       err = dssnt(DFNT_FLOAT64)
  187.       print *,'Add float64 ret: ',dsadata('ntf.hdf',rank,dims,f64)
  188.  
  189.       err = dssnt(DFNT_FLOAT32)
  190.       print *,'Add float32 ret: ',dsadata('ntf.hdf',rank,dims,f32)
  191.  
  192.       err = dssnt(DFNT_INT8)
  193.       print *, 'Add int8 ret: ', dsadata('ntf.hdf', rank, dims, i8)
  194.  
  195.       err = dssnt(DFNT_INT16)
  196.       print *, 'Add int16 ret: ', dsadata('ntf.hdf', rank, dims, i16)
  197.  
  198.       err = dssnt(DFNT_INT32)
  199.       print *, 'Add int32 ret: ', dsadata('ntf.hdf', rank, dims, i32)
  200.  
  201.       print *, 'Reading arrays from single file... '
  202.       print *, 'Error values: '
  203. C
  204.       print *, 'Get f64 ret: ', dsgdata('ntf.hdf', rank, dims, tf64)
  205.       print *, 'Get f32 ret: ', dsgdata('ntf.hdf', rank, dims, tf32)
  206.       print *, 'Get int8 ret: ', dsgdata('ntf.hdf', rank, dims, ti8)
  207.       print *, 'Get int16 ret: ', dsgdata('ntf.hdf', rank, dims, ti16)
  208.       print *, 'Get int32 ret: ', dsgdata('ntf.hdf', rank, dims, ti32)
  209.  
  210.       print *, 'Checking arrays from single file...\n\n'
  211.  
  212.       err = 0
  213.       do 910 i=1,10
  214.          do 900 j=1,10
  215.            if (f64(i,j) .ne. tf64(i,j)) err = 1
  216.   900    continue
  217.   910 continue
  218.  
  219.       call err_check(err, number_failed, 'float64')
  220.  
  221.       err = 0
  222.       do 1010 i=1,10
  223.          do 1000 j=1,10
  224.            if (f32(i,j) .ne. tf32(i,j)) err = 1
  225.  1000    continue
  226.  1010 continue
  227.  
  228.       call err_check(err, number_failed, 'float32')
  229.       err = 0
  230.       do 1110 i=1,10
  231.          do 1100 j=1,10
  232.            if (i8(i,j) .ne. ti8(i,j)) err = 1
  233.  1100    continue
  234.  1110 continue
  235.  
  236.       call err_check(err, number_failed, 'int8')
  237.       err = 0
  238.       do 1210 i=1,10
  239.          do 1200 j=1,10
  240.            if (i16(i,j) .ne. ti16(i,j)) err = 1
  241.  1200    continue
  242.  1210 continue
  243.  
  244.       call err_check(err, number_failed, 'int16')
  245.       err = 0
  246.       do 1310 i=1,10
  247.          do 1300 j=1,10
  248.            if (i32(i,j) .ne. ti32(i,j)) err = 1
  249.  1300    continue
  250.  1310 continue
  251.  
  252.       call err_check(err, number_failed, 'int32')
  253.       print *
  254.       if (number_failed .gt. 0 ) then
  255.       print *,'        >>> ', number_failed, ' TESTS FAILED <<<'
  256.       else
  257.       print *,'        >>> ALL TESTS PASSED <<<'
  258.       endif
  259.       print *
  260.       print *
  261.  
  262.       stop
  263.       end  
  264.   
  265. C
  266. C
  267.       subroutine err_check(err, num_fail, type)
  268.       integer err, num_fail
  269.       character*(*) type
  270.  
  271.       if (err .eq. 1) then 
  272.       print *,'>>> Test failed for ',type, ' array.'
  273.         num_fail = num_fail+1
  274.       else
  275.       print *,'Test passed for ', type, ' array.'
  276.       endif
  277.  
  278.       return
  279.       end
  280.  
  281.